package cn.edu.baiyunu.myapplication.ui.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

/**
 * 圆点图案背景组件 - 模仿原型图中的pattern-dots效果
 */
@Composable
fun PatternDotsBackground(
    modifier: Modifier = Modifier
) {
    Box(
        modifier = modifier.fillMaxSize()
    ) {
        Canvas(modifier = Modifier.fillMaxSize()) {
            val dotRadius1 = 2.dp.toPx()
            val dotRadius2 = 2.dp.toPx()
            val spacing = 30.dp.toPx()
            val halfSpacing = 15.dp.toPx()
            
            val width = size.width
            val height = size.height
            
            val primaryColor = Color(0xFF6366F1).copy(alpha = 0.08f)
            val secondaryColor = Color(0xFFC084FC).copy(alpha = 0.08f)
            
            // 绘制主要圆点阵列
            var y = 0f
            while (y < height) {
                var x = 0f
                while (x < width) {
                    drawCircle(
                        color = primaryColor,
                        radius = dotRadius1,
                        center = Offset(x, y)
                    )
                    x += spacing
                }
                y += spacing
            }
            
            // 绘制次要圆点阵列，偏移15dp
            y = halfSpacing
            while (y < height) {
                var x = halfSpacing
                while (x < width) {
                    drawCircle(
                        color = secondaryColor,
                        radius = dotRadius2,
                        center = Offset(x, y)
                    )
                    x += spacing
                }
                y += spacing
            }
        }
    }
} 